﻿using System.Windows;
using System.Windows.Controls;
using yzrilyzr.FAQ.constants;

namespace FAQ_UI
{
	/// <summary>
	/// SetPath.xaml 的交互逻辑
	/// </summary>
	public partial class SetPath : Page
	{
		public SetPath()
		{
			InitializeComponent();
			DataContext = this;
		}

		private void Page_Loaded(object sender, RoutedEventArgs e)
		{
			ClientPath.Text = FAQUtil.getClientPath();
			ServerPath.Text = FAQUtil.getServerPath();
		}

		private void Page_Unloaded(object sender, RoutedEventArgs e)
		{
			FAQUtil.settings.put(D.SETTINGS, "ClientPath", ClientPath.Text);
			FAQUtil.settings.put(D.SETTINGS, "ServerPath", ServerPath.Text);
			FAQUtil.settings.save();
		}

		private void ServerPath_TextChanged(object sender, TextChangedEventArgs e)
		{
			FAQUtil.settings.put(D.SETTINGS, "ServerPath", ServerPath.Text);
			FAQUtil.settings.delaySave(500);
		}

		private void ClientPath_TextChanged(object sender, TextChangedEventArgs e)
		{
			FAQUtil.settings.put(D.SETTINGS, "ClientPath", ClientPath.Text);
			FAQUtil.settings.delaySave(500);
		}
	}
}